<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-1-31
 * Time: 下午3:03
 */

namespace common\models;

/**
 * Class CarOrderLog
 * @package common\models
 *
 * @property CarOrderBankBackLog[] $carOrderBankBackLogs
 * @property CarOrderBankBackLog $lastCarOrderBankBackLog
 * @property CarOrder $carOrder
 */
class CarOrderLog extends \common\models\base\CarOrderLog
{
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCarOrderBankBackLogs()
    {
        return $this->hasMany(CarOrderBankBackLog::className(), ['for_serial_number' => 'serial_number']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getLastCarOrderBankBackLog()
    {
        return $this->hasOne(CarOrderBankBackLog::className(), ['for_serial_number' => 'serial_number'])->orderBy(['id'=>SORT_DESC]);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCarOrder()
    {
        return $this->hasOne(CarOrder::className(), ['id' => 'car_order_id']);
    }
}